﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Satates.CMStates;

namespace Operators.CMOperators
{
    public class Move2CanibalRight : iOperator
    {
        public override string ToString()
        {

            return "Move 2 Canibal Right";
        }

        public int getOperatorNumber()
        {
            return 4;
        }

        public Common.Template execute(Common.Template t)
        {
            CMState s2 = (CMState)t;
            s2.setLeftCanibals(s2.getLeftCanibals() - 2);
            s2.setRightCanibals(s2.getRightCanibals() + 2);
            s2.setBoat("right");
            return s2;
        }

        public bool available(Common.Template t)
        {
            CMState s = (CMState)t;
            if (s.getBoat().Equals("left"))
                if (s.getLeftCanibals() >= 2)
                    if ((s.getRightCanibals() + 2 <= s.getRightMissionaries()) || (s.getRightMissionaries() == 0))
                        return true;
            return false;
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
}
